#include <stdio.h>
#include <stdlib.h>

typedef struct _node
{
	int value;
	struct _node *next;
	struct _node *last;
}Node;
typedef struct 
{
	Node *head;
	Node *tail;
}List;

void print(List *plist);
void add(List *plist,int number);

int main(int argc, char const *argv[])
{
	List list;
	list.head=list.tail=NULL;
	int number;
	do
	{
		scanf("%d",&number);
	 	if(number!=-1)
	 	{
	 		add(&list,number);		
		}
	} while(number!=-1);
	print(&list);
	
	return 0;
}
void add(List *plist,int number)
{
	//set the list
	Node *p=(Node*)malloc(sizeof(Node));
	p->value=number;
	p->next=NULL;
	if (plist->head)
	{
		//attach
		plist->tail->next=p;
		p->last=plist->tail->next;
		//find the tail
		plist->tail=p;
	}else{
		plist->head=p;
		plist->tail=p;
		p->last=NULL;
	}
	
}
void print(List *plist)
{
	Node  *p;
	for (p=plist->head;p;p=p->next)
	{
		printf("%-4d",p->value );
		printf("next=%p\t", p->next);
		printf("last=%p\n",p->last);
	}
}
